home *** CD-ROM | disk | FTP | other *** search
- unit uExploreView;
-
- {
- *******************************************************************************
- * Descriptions: Main Unit for FMA
- * $Source: /cvsroot/fma/fma/uExploreView.pas,v $
- * $Locker: $
- *
- * Todo:
- * - add full popup menu
- *
- * Change Log:
- * $Log: uExploreView.pas,v $
- * Revision 1.13 2004/06/30 15:25:53 z_stoichev
- * Added Create Group menu item
- *
- * Revision 1.12 2004/06/27 21:19:21 z_stoichev
- * Explore phone WAP bookmarks.
- *
- * Revision 1.11 2004/06/25 15:23:27 z_stoichev
- * Bookmark support
- *
- * Revision 1.10 2004/06/24 09:06:06 z_stoichev
- * - Added Chat to Contact command to various popup menus.
- * - Added Add to Phonebook to various popup menus.
- *
- * Revision 1.9 2004/06/19 11:17:31 z_stoichev
- * - Changed Contact Group icons.
- *
- * Revision 1.8 2004/05/21 12:03:09 z_stoichev
- * Profile context menu and properties.
- *
- * Revision 1.7 2004/05/19 18:34:15 z_stoichev
- * Build 0.1.0.35c
- *
- * Revision 1.6 2004/04/01 15:30:28 z_stoichev
- * New Calls data format support
- *
- * Revision 1.5 2004/03/08 15:53:52 z_stoichev
- * Fixed Explorer view foder types.
- * Added Explorer view default properties.
- *
- * Revision 1.4 2004/01/28 17:13:09 z_stoichev
- * Popup menu rearranged.
- *
- * Revision 1.3 2003/12/12 12:57:22 z_stoichev
- * Add delete file support.
- * Add properties link.
- * Add customize view support.
- *
- * Revision 1.2 2003/11/28 09:38:07 z_stoichev
- * Merged with branch-release-1-1 (Fma 0.10.28c)
- *
- * Revision 1.1.2.8 2003/11/21 16:18:30 z_stoichev
- * Show calls time in second column.
- *
- * Revision 1.1.2.7 2003/11/14 15:41:02 z_stoichev
- * Updates for patch 27d.
- *
- * Revision 1.1.2.6 2003/11/13 16:39:54 z_stoichev
- * Add more items type support.
- *
- * Revision 1.1.2.5 2003/11/11 13:18:12 z_stoichev
- * Update since new icons.
- * Optimized contents reload.
- *
- * Revision 1.1.2.4 2003/11/10 14:03:09 z_stoichev
- * RC3
- *
- * Revision 1.1.2.3 2003/11/06 16:27:20 z_stoichev
- * Popup menu expanded.
- * Dont show -1 size.
- *
- * Revision 1.1.2.2 2003/11/04 12:27:26 z_stoichev
- * Display size in Kb for files and hide for folders.
- * Added amr sound type support.
- *
- * Revision 1.1.2.1 2003/10/29 09:20:50 z_stoichev
- * Initial checkin.
- *
- }
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ExtCtrls, VirtualTrees, TntComCtrls, Menus, Placemnt;
-
- type
- TfrmExplore = class(TFrame)
- ListItems: TVirtualStringTree;
- NoItemsPanel: TPanel;
- PopupMenu1: TPopupMenu;
- Explore1: TMenuItem;
- newmsg1: TMenuItem;
- newcall1: TMenuItem;
- N3: TMenuItem;
- Delete1: TMenuItem;
- N4: TMenuItem;
- New1: TMenuItem;
- Note1: TMenuItem;
- Bookmark1: TMenuItem;
- sms1: TMenuItem;
- person1: TMenuItem;
- download1: TMenuItem;
- FormStorage1: TFormStorage;
- Upload1: TMenuItem;
- N5: TMenuItem;
- Properties1: TMenuItem;
- N7: TMenuItem;
- ActivatePr1: TMenuItem;
- ChatContact1: TMenuItem;
- SendandReceive1: TMenuItem;
- N1: TMenuItem;
- AddToPhonebook1: TMenuItem;
- NewGroup1: TMenuItem;
- procedure ListItemsGetImageIndex(Sender: TBaseVirtualTree;
- Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
- var Ghosted: Boolean; var ImageIndex: Integer);
- procedure ListItemsGetText(Sender: TBaseVirtualTree;
- Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
- var CellText: WideString);
- procedure Open1Click(Sender: TObject);
- procedure Properties1Click(Sender: TObject);
- procedure PopupMenu1Popup(Sender: TObject);
- private
- FRootNode: TtntTreeNode;
- procedure Set_RootNode(const Value: TtntTreeNode);
- { Private declarations }
- public
- { Public declarations }
- property RootNode: TtntTreeNode read FRootNode write Set_RootNode default nil;
- end;
-
- TExploreItem = record
- name,descr,param: WideString;
- end;
- PExploreItem = ^TExploreItem;
-
- implementation
-
- uses uGlobal, Unit1;
-
- {$R *.dfm}
-
- procedure TfrmExplore.Set_RootNode(const Value: TtntTreeNode);
- var
- i: integer;
- s: string;
- Node: PVirtualNode;
- Item: PExploreItem;
- begin
- FRootNode := Value;
- ListItems.BeginUpdate;
- try
- ListItems.Clear;
- ListItems.NodeDataSize := SizeOf(TExploreItem);
- for i := 0 to FRootNode.Count-1 do begin
- Node := ListItems.AddChild(nil);
- Node.Dummy := FRootNode.Item[i].ImageIndex;
- Item := ListItems.GetNodeData(Node);
- Item.name := FRootNode.Item[i].Text;
- case Node.Dummy of
- 1..3,5..7,19..22,30..35,39..43,46..50,56,57: begin
- Item.descr := 'Folder';
- Item.param := '';
- continue;
- end;
- 8: Item.descr := 'Contact';
- 9..13: Item.descr := 'Phone number';
- 24: Item.descr := 'Profile';
- 26,58: Item.descr := 'Group';
- 59: Item.descr := 'Bookmark';
- 27,36..38: begin // if you change this see Form1.Remove1Click() too!!
- s := ExtractFileExt(Item.name);
- if (s = '.amr') then
- Item.descr := 'Speech'
- else
- if (s = '.mid') or (s = '.imy') then
- Item.descr := 'Sound'
- else
- if (s = '.gif') or (s = '.jpg') or (s = '.wbmp') then
- Item.descr := 'Picture'
- else
- if (s = '.thm') then
- Item.descr := 'Theme'
- else
- Item.descr := 'File';
- Item.param := Format('%.1n Kb',[FRootNode.Item[i].StateIndex / 1024]);
- continue;
- end;
- 53..55: begin // calls
- Item.descr := GetToken(TStrings(FRootNode.Data)[FRootNode.Item[i].StateIndex-1],1);
- end;
- else
- Item.descr := 'Undefined';
- end;
- if FRootNode.Item[i].StateIndex <> -1 then
- Item.param := IntToStr(FRootNode.Item[i].StateIndex)
- else
- Item.param := '';
- end;
- finally
- if (Form1.Explorer.Selected = Form1.FindObexFolderNode(0)) or
- (Form1.Explorer.Selected = Form1.FindObexFolderNode(1)) or
- (Form1.Explorer.Selected = Form1.FindObexFolderNode(2)) then
- ListItems.TreeOptions.SelectionOptions := ListItems.TreeOptions.SelectionOptions + [toMultiSelect]
- else
- ListItems.TreeOptions.SelectionOptions := ListItems.TreeOptions.SelectionOptions - [toMultiSelect];
- ListItems.EndUpdate;
- NoItemsPanel.Visible := FRootNode.Count = 0;
- end;
- end;
-
- procedure TfrmExplore.ListItemsGetImageIndex(Sender: TBaseVirtualTree;
- Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
- var Ghosted: Boolean; var ImageIndex: Integer);
- begin
- if Column = 0 then
- if (Kind = ikNormal) or (Kind = ikSelected) then
- ImageIndex := Node.Dummy;
- end;
-
- procedure TfrmExplore.ListItemsGetText(Sender: TBaseVirtualTree;
- Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
- var CellText: WideString);
- var
- Item: PExploreItem;
- begin
- Item := ListItems.GetNodeData(Node);
- case Column of
- 0: CellText := Item.name;
- 1: CellText := Item.descr;
- 2: CellText := Item.param;
- end;
- end;
-
- procedure TfrmExplore.Open1Click(Sender: TObject);
- var
- Item: PExploreItem;
- Node: PVirtualNode;
- Child: TTntTreeNode;
- begin
- Node := ListItems.FocusedNode;
- if Node <> nil then begin
- Item := ListItems.GetNodeData(Node);
- Child := Form1.FindExplorerChildNode(Item.name);
- if Child <> nil then Form1.Explorer.Selected := Child;
- end;
- end;
-
- procedure TfrmExplore.Properties1Click(Sender: TObject);
- var
- Item: PExploreItem;
- Node: PVirtualNode;
- Child: TTntTreeNode;
- begin
- Node := ListItems.FocusedNode;
- if Node <> nil then begin
- Item := ListItems.GetNodeData(Node);
- Child := Form1.FindExplorerChildNode(Item.name);
- if Child <> nil then Form1.ShowExplorerProperties(Child);
- end
- else
- Form1.ShowExplorerProperties(Form1.Explorer.Selected);
- end;
-
- procedure TfrmExplore.PopupMenu1Popup(Sender: TObject);
- var
- Item: PExploreItem;
- Node: PVirtualNode;
- Child: TTntTreeNode;
- begin
- Properties1.Enabled := ListItems.SelectedCount <= 1;
- Explore1.Enabled := Properties1.Enabled;
- ActivatePr1.Visible := False;
- if ListItems.SelectedCount = 1 then begin
- Node := ListItems.FocusedNode;
- if Node <> nil then begin
- Item := ListItems.GetNodeData(Node);
- Child := Form1.FindExplorerChildNode(Item.name);
- if (Child <> nil) and (Child.ImageIndex = 24) then begin
- ActivatePr1.Enabled := Child.Text <> Form1.cbProfile.Text;
- ActivatePr1.Visible := True;
- end;
- end;
- end;
- end;
-
- end.
-